{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 4,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    "from pizco import Proxy\n",
    "import ipywidgets as widgets\n",
    "mmvt = Proxy('tcp://127.0.0.1:8000')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 19,
   "metadata": {
    "collapsed": false
   },
   "outputs": [],
   "source": [
    "def on_value_change(change):\n",
    "    t = change['new']\n",
    "    mmvt.rotate_brain(0, 0, 0.1)\n",
    "    file = open(mmvt.plot_meg(t, True), \"rb\")\n",
    "    meg.value = file.read()\n",
    "\n",
    "mmvt.show_sagital()\n",
    "file = open(mmvt.plot_meg(0, True), \"rb\")\n",
    "meg = widgets.Image(value=file.read(), format='png', width=800, height=450)\n",
    "play = widgets.Play(value=0, min=0, max=2500, step=100, interval=1000)\n",
    "slider = widgets.IntSlider(min=0, max=2500, value=0, step=100)\n",
    "slider.observe(on_value_change, names='value')    \n",
    "\n",
    "widgets.jslink((play, 'value'), (slider, 'value'))\n",
    "widgets.VBox([widgets.HBox([play, slider]), meg])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "collapsed": true
   },
   "outputs": [],
   "source": [
    ""
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3.0
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 0
}